package br.com.ir.tcc.geco.modelo;

// default package
// Generated 23/08/2009 11:59:00 by Hibernate Tools 3.2.5.Beta

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * CombinacaoTemplate generated by hbm2java
 */
@Entity
@Table(name = "combinacaotemplate", catalog = "tcc")
public class CombinacaoTemplate implements java.io.Serializable, Comparable<CombinacaoTemplate>{

	private static final long serialVersionUID = -4834534313462436884L;
	
	private Integer id;
	private Template template;
	private Combinacao combinacao;
	private String chaveObjetoModelo;
	private Integer ordem;
	private String fontePrincipal;

	public CombinacaoTemplate() {
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "template_id", nullable = false)
	public Template getTemplate() {
		return this.template;
	}

	public void setTemplate(Template template) {
		this.template = template;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "combinacao_id", nullable = false)
	public Combinacao getCombinacao() {
		return this.combinacao;
	}

	public void setCombinacao(Combinacao combinacao) {
		this.combinacao = combinacao;
	}

	@Column(name = "chaveObjetoModelo", nullable = false, length = 500)
	public String getChaveObjetoModelo() {
		return this.chaveObjetoModelo;
	}

	public void setChaveObjetoModelo(String chaveObjetoModelo) {
		this.chaveObjetoModelo = chaveObjetoModelo;
	}

	public Integer getOrdem() {
		return this.ordem;
	}

	public void setOrdem(Integer ordem) {
		this.ordem = ordem;
	}

	public Integer getNivel() {
		return chaveObjetoModelo != null 
				? chaveObjetoModelo.split("\\.").length
				: -1;
	}
	
	public void setNivel(Integer nivel){}

	public String getFontePrincipal() {
		return fontePrincipal;
	}

	public void setFontePrincipal(String fontePrincipal) {
		this.fontePrincipal = fontePrincipal;
	}

	@Override
	public int compareTo(CombinacaoTemplate o) {
		return ordem.compareTo(o.getOrdem());
	}

}
